package com.one.consumer.main.presenter;

import android.content.Context;

import com.one.common.model.bean.BannerBean;
import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.presenter.BaseApiPresenter;
import com.one.common.view.base.BaseActivity;
import com.one.consumer.main.model.MainModel;
import com.one.consumer.main.ui.view.BannerView;

import org.xutils.common.util.LogUtil;

import java.util.ArrayList;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/21 下午1:55
 * description ：
 **/
public class HomePresenter extends BaseApiPresenter<BannerView, MainModel> {

    public HomePresenter(BannerView mView, Context mContext) {
        super(mView, mContext, new MainModel((BaseActivity) mContext));
    }


    /**
     * 获取首页banner
     */
    public void getBanner() {
        mModel.getBanner(new ObserverOnResultListener<ArrayList<BannerBean>>() {
            @Override
            public void onResult(ArrayList<BannerBean> bannerBeans) {
                if (mView != null) {
                    mView.setBanner(bannerBeans);
                }
            }
        });
    }

    /**
     * 获取首页信息
     */
    public void getMainInfo() {
        mModel.getMainInfo(new ObserverOnResultListener<String>() {
            @Override
            public void onResult(String bannerBeans) {
//                if (mView != null) {
//                    mView.setBanner(bannerBeans);
//                }
                LogUtil.e("getMainInfo "+bannerBeans);
            }
        });
    }

}
